#include <iostream>

using namespace std;

struct section{
	int left;
	int right;
};

int main(){
	int roadLength = 0;
	cin >> roadLength;
	//申请roadLength+1个bool  : road 
	bool * road = new bool[roadLength + 1];

	//初始化road为false 
	for (int i = 0; i <= roadLength; i++)
		road[i] = false;

	int sectionCount;
	cin >> sectionCount;


	section * list = new section[sectionCount];

	for (int i = 0; i < sectionCount; i++)
		cin >> list[i].left >> list[i].right;

	for (int i = 0; i < sectionCount; i++){
		for (int j = list[i].left; j <= list[i].right; j++)
			road[j] = true;
	}

	int allCount = 0;
	for (int i = 0; i <= roadLength; i++)
	if (road[i] == false) allCount++;
	cout << allCount << endl;
	return 0;
}
